package org.hhchat.leetcode.bit;

import java.util.Stack;

/**
 * Created by hh23485 on 2017/6/25.
 */
public class code476 {
    public static class Solution {
        public int findComplement(int num) {
            int count=0;
            Stack<Integer> stack=new Stack<>();
            while(num>0){
                stack.push(1-num%2);
                num/=2;
            }
            while(!stack.empty()){
                count=count*2+stack.pop();
            }
            return count;
        }
    }
    public static void main(String[] args){
        System.out.println(new Solution().findComplement(0));
    }
}
